package com.ibeetl.admin.core.util.beetl;

import org.beetl.core.Context;
import org.beetl.core.Function;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.ibeetl.admin.core.rbac.tree.CatalogItem;
import com.ibeetl.admin.core.service.CorePlatformService;

/**
 * 通过catalogId获取catalogName,从缓存中获取
 */
@Component
public class CatalogFunction implements Function {

	@Autowired
	CorePlatformService platFormService;
	
	
	public Object call(Object[] paras, Context ctx) {
		CatalogItem tree = platFormService.buildCatalog();
		CatalogItem item = tree.findChild((Long)paras[0]);
		if (item != null) {
			return item.getName();
		} else {
			return null;
		}
	}
	
	

}
